﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HotelManagement.Class;

namespace HotelManagement.UserManagementModule
{
    public partial class ChangeMyPassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                Label9.Visible = false; //not to display false error msg to user
                UserAccount us=(UserAccount)Session["object"];
                Label3.Text=us.FirstName + " " + us.LastName; //heading
            
        }

        protected void Button4_Click(object sender, EventArgs e) //change Password button
        {
            if (TextBox1.Text == ((UserAccount)Session["object"]).Password){ //password is correct
                
                if (HotelDBManager.updatePasswordByUserID(((UserAccount)Session["object"]).UserID, TextBox2.Text) == 1) //update success
                {
                    Response.Redirect("~/UserManagementModule/ChangePasswordSuccess.aspx");
                }
                else { //update fail
                    Label1.Visible = true;
                }

            }
            else{ //password not correct
                Label9.Visible = true;
            }
        }
    }
}